package main

import "fmt"

func incrementor() chan int {
	out := make(chan int)
	go func() {
		for i := 0; i < 10; i++ {
			out <- i
		}
		close(out)
	}()
	return out
}

func puller(in chan int) chan int {
	out := make(chan int)
	go func() {
		var sum int
		for v := range in {
			sum += v
		}
		out <- sum
		close(out)
	}()
	return out
}

func main() {
	ints := incrementor()
	sumChan := puller(ints)
	fmt.Println(<-sumChan)
}
